package com.magic.easyexcel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.*;

/**
 * @author laoma
 * @create 2021-06-06 11:06
 */
public class EasyTest2 {
    public static void main(String[] args) {
        List<Listener> list = new LinkedList<>();
        EasyExcel.read("F:\\java-workspace\\malearn\\easyexcel\\listener.xlsx")
                .sheet()
                .head(Listener.class)
                // .head() 返回实体映射类型，默认是 LinkHashMap
                .registerReadListener(new AnalysisEventListener<Listener>() {
                    @Override
                    public void invoke(Listener listener, AnalysisContext analysisContext) {
                        list.add(listener);
                    }

                    @Override
                    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
                        System.out.println("数据读取完毕");
                    }
                }).doRead();
        for (Listener listener : list) {
            System.out.println(listener);
        }
    }
}
